home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / -archivi / -recent2 / gaplib.lha / GAPLib_Beta / diagnostic / TagListTest.c < prev   
C/C++ Source or Header  |  1999-02-07  |  2KB  |  88 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <GAP.h>
  4.  
  5. struct Testyphant {
  6.     long int    foo[4];
  7. };
  8.  
  9. double    dummy_evaluator(struct Testyphant *);
  10. void    dummy_crosser(struct Testyphant*,struct Testyphant*);
  11.  
  12. int main(void)
  13. {
  14. int ret=0;
  15. struct Population *Pop;
  16. struct Testyphant *Testy;
  17.  
  18. struct TagItem TestTags[] = {
  19.     {EVL_Mutator,NULL},
  20.     {EVL_Evaluator,0L},
  21.     {TAG_IGNORE,4711L},
  22.     {TAG_MORE,0L},
  23.     {EVL_Stats,FALSE},    /* These two lines should never */
  24.     {TAG_DONE,0L}            /* be used if all is well. */
  25. };
  26.  
  27. struct TagItem Test2Tags[] = {
  28.     {TAG_IGNORE,17L},
  29.     {EVL_Crosser,(IPTR)dummy_crosser},
  30.     {TAG_DONE,0L}
  31. };
  32.  
  33. struct TagItem PopTags[] = {
  34.     {POP_Init,ZERO_INIT},
  35.     {POP_Cache,TRUE},
  36.     {TAG_END,0L}
  37. };
  38.  
  39. Pop = CreatePopulation(24,sizeof(struct Testyphant),PopTags);
  40.  
  41. if(Pop!=NULL) {
  42.     TestTags[0].ti_Data = (IPTR) dummy_evaluator;
  43.     TestTags[2].ti_Data = (IPTR) Test2Tags;
  44.  
  45.     Pop = Evolve(Pop,TestTags);
  46.  
  47.     Testy = PopMember(Pop,1);
  48.  
  49.     if(Testy->foo[0] == 0) {
  50.         printf("Possible error in TAG_MORE handling.\n");
  51.         ret++;
  52.         if(Pop->Stat.Generation == Pop->Generation) {
  53.             printf("Possible error in TAG_IGNORE handling.\n");
  54.             ret++;
  55.         }
  56.     }
  57.  
  58.     if(Pop->Stat.Generation != Pop->Generation) {
  59.         printf("Possible error in TAG_MORE handling.\n");
  60.         ret++;    
  61.     }
  62.  
  63.     DeletePopulation(Pop);
  64. } else {
  65.     printf("Population Creation Failed.\n");
  66.     ret = 20;
  67. }
  68.  
  69. if(ret==0) {
  70.     printf("Seems ok.\n");
  71. }
  72.  
  73. return(0);
  74. }
  75.  
  76. double    dummy_evaluator(struct Testyphant *t)
  77. {
  78. static int i=0;
  79. return((double)i++);
  80. }
  81.  
  82. void    dummy_crosser(struct Testyphant *Polly,struct Testyphant *Tweety)
  83. {
  84. memset(Polly,0xff,sizeof(struct Testyphant));
  85. memset(Tweety,0xff,sizeof(struct Testyphant));
  86. }
  87.  
  88.